#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N=20;
#define INF 0x7fffffff
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//
int n=16;
int st[N];
int used[N];

void dfs(int u)
{
	if (u > n)
	{
		for (int i = 1; i <n; i++)
		{
			int sum1=0,sum2=0,sq1=0,sq2=0,cub1=0,cub2=0;
			for(int j=1;j<=i;j++)
			{
				sum1+=st[j];sq1+=j*j;cub1=j*j*j;
			}
			for(int j=i+1;j<=n;j++)
			{
				sum2+=st[j];sq2+=j*j;cub2=j*j*j;
			}
			if(sum1==sum2&&sq1==sq2&&cub1==cub2)
			{
				for(int i=1;i<=n;i++) cout<<st[i]<<" ";
			}
		}
		return;
	}

	for (int i = 1; i <= n; i++)
	{
		if (!used[i])
		{
			st[u] = i;
			used[i] = true;
			dfs(u + 1);
			st[u] = 0;
			used[i] = false;
		}
	}
}

int main()
{

	dfs(1);
	return 0;
}